1 using System;
2 using
System.Collections.Generic;
3 using
System.ComponentModel;
4 using
System.Data;
5 using
System.Drawing;
6 using
System.Text;
7 using
System.Windows.Forms;
8 using
Microsoft.Office.Interop.Word;
9
10 namespace
TruyXuatFile
11 {
12     
public partial class frmWord : Form
13     {
14         
public frmWord()
15         {
16             InitializeComponent();
17         }
18
19         
public string PathNameWord;
20         
public string GetPathWord(string pnw)
21         {
22             PathNameWord = pnw;
23             
return PathNameWord;
24         }
25
26
27
28         
private void frmWord_Load(object sender, EventArgs e)
29         {
30             txtPath.Text = PathNameWord;
31             btnOpenWordDocument_Click(sender, e);
32         }
33
34         
private void btnOpenWordDocument_Click(object sender, EventArgs e)
35         {
36             ApplicationClass wordApp =
new ApplicationClass();
37             
string PathNameWord = txtPath.Text;
38             
object wFileName = PathNameWord ;
39             
object wConfirmConversions = true;
40             
object wReadOnly = true;
41             
object wAddToRecentFiles = true;
42             
object wPasswordDocument = "";
43             
object wPasswordTemplate = "";
44             
object wRevert = true;
45             
object wWritePasswordDocument = "";
46             
object wWritePasswordTemplate = "";
47             
object wFormat = WdOpenFormat.wdOpenFormatAuto;
48             
object wEncoding = Microsoft.Office.Core.MsoEncoding.msoEncodingAutoDetect;
49             
object wVisible = true;
50             
object wOpenAndRepair = true;
51             
object wDocumentDirection = WdDocumentDirection.wdRightToLeft;
52             
object wNoEncodingDialog = false;
53             
object wXMLTransform = System.Reflection.Missing.Value;
54
55             
object nullobj = System.Reflection.Missing.Value;
56             wordApp.Visible =
true;
57             Document doc = wordApp.Documents.Open(
ref wFileName, ref wConfirmConversions, ref nullobj,
58                                                    
ref wAddToRecentFiles, ref wPasswordDocument, ref wPasswordTemplate,
59                                                    
ref wRevert, ref wWritePasswordDocument, ref wWritePasswordTemplate,
60                                                    
ref wFormat, ref wEncoding, ref wVisible, ref wOpenAndRepair,
61                                                    
ref wDocumentDirection, ref wNoEncodingDialog, ref wXMLTransform);
62         }
63
64         
private void btnBrowse_Click_1(object sender, EventArgs e)
65         {
66             openFileDialog1.FileName = txtPath.Text;
67             openFileDialog1.Filter =
" Document File(*.doc*)|*.doc*";
68             openFileDialog1.ShowDialog();
69             
string PathNameWord = openFileDialog1.FileName;
70             txtPath.Text = PathNameWord;
71         }
72
73         
private void btnClose_Click(object sender, EventArgs e)
74         {
75             
this.Close();
76         }
77     }
78 }



Phần mềm hỗ trợ truy xuất file C# 3.507 lượt xem

Gõ tìm kiếm nhanh...